package com.lrh.java8;

import java.util.Arrays;
import java.util.stream.Stream;

public class StreamMatch {

    public static void main(String[] args) {
        Stream<Integer> stream = Arrays.stream(new Integer[]{
                1,2,3,4,5,67
        });

        //所有的元素都要匹配返回true
        boolean matched = stream.allMatch(i -> i > 10);
        System.out.println(matched);

        stream = Arrays.stream(new Integer[]{
                1,2,3,4,5,67
        });

        //有一个及以上匹配返回true
        matched = stream.anyMatch(i -> i > 4);
        System.out.println(matched);

        stream = Arrays.stream(new Integer[]{
                1,2,3,4,5,6,7
        });

        //所有的元素都要匹配返回true
        matched = stream.noneMatch(i -> i < 0);
        System.out.println(matched);
    }
}
